/**
 * Created by R.Lao on 2017/6/26.
 */
var trackMap = {
		
	// 查询轨迹
    queryTrack:function(url,data,back){
    	$.ajax({
		 	url:appCtx+"gis/playback/queryList.html",
            success : function(data){
                if(data){
                	var result = JSON.parse(data);
                	back(result);
                }
            }
	 });
    },
    
    // 画轨迹
    drawTrack:function(map,lineArr,carPic,trackColor,passTrackColor,lineSize){
    	
    	marker = new AMap.Marker({
	        map: map,
	        position: lineArr[0],
	        icon: carPic,
	        offset: new AMap.Pixel(-26, -13),
	        autoRotation: true
	    });
	    
	    startMarker = new AMap.Marker({
	        map: map,
	        position: lineArr[0],
	        icon: appCtx + "resources/images/mapTool/p_start.png",
	        offset: new AMap.Pixel(-15, -30)
	    });
	    
	    endMarker = new AMap.Marker({
	        map: map,
	        position: lineArr[lineArr.length-1],
	        icon: appCtx + "resources/images/mapTool/p_end.png",
	        offset: new AMap.Pixel(-15, -30)
	    });

	    // 绘制轨迹
	    var polyline = new AMap.Polyline({
	        map: map,
	        path: lineArr,
	        strokeColor: trackColor,  //线颜色
	        // strokeOpacity: 1,     //线透明度
	        strokeWeight: lineSize,      //线宽
	        // strokeStyle: "solid"  //线样式
	    });
	    
	    var passedPolyline = new AMap.Polyline({
	        map: map,
	        strokeColor: passTrackColor,  //线颜色
	        strokeWeight: lineSize,      //线宽
	    });
	    
	    marker.on('moving',function(e){
	        passedPolyline.setPath(e.passedPath);
	    })
	    //map.setFitView();
	    
//	    AMap.event.addDomListener(document.getElementById('start'), 'click', function() {
//	        marker.moveAlong(lineArr, 500);
//	    }, false);
//	     AMap.event.addDomListener(document.getElementById('pause'), 'click', function() {
//	        marker.pauseMove();
//	       }, false);
//	      AMap.event.addDomListener(document.getElementById('resume'), 'click', function() {
//	        marker.resumeMove();
//	    }, false);
//	    AMap.event.addDomListener(document.getElementById('stop'), 'click', function() {
//	        marker.stopMove();
//	    }, false);
    }
}
